package com.shr.code_interview;

public class Solution_4 {
    public static boolean find(int target, int [][] array) {
        int colLen = array[0].length - 1 ;
        int rowLen = 0;
        while(colLen >= 0 && rowLen < array.length){
        	if(array[rowLen][colLen] == target)
        		return true;
        	else{
        		if(array[rowLen][colLen] < target)
        			rowLen++ ;
        		else colLen -- ;
        	}
        }
        return false ;
    }
    
    public static void main(String[] args) {
		int[][] a = {{1,2,8,9},{2,4,9,12},{4,7,10,13},{6,8,11,15}};
		System.out.println(find(8,a));
	}
}
